package threads;

import java.util.concurrent.Phaser;

public class PrintAZ026Test_Phaser {
    public static void main(String[] args) {
        Phaser phaser = new Phaser(2){
            @Override
            protected boolean onAdvance(int phase, int registeredParties) {
               // System.out.println(phase+","+registeredParties);
                return false;
            }
        };
        Thread t1 = new Thread(() -> {
            for (int i = 'A'; i <= 'Z'; i++) {
                phaser.arriveAndAwaitAdvance();
                System.out.println((char) i);
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 1; i <= 26; i++) {
                phaser.arriveAndAwaitAdvance();
                System.out.println(i);
            }
        });
        t1.start();
        t2.start();
    }
}
